package day11.gec.close;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDK7CloseDemo2 {
	public static void main(String[] args) {
		//注册驱动
		try {
			//mysql com.mysql.cj.jdbc.Driver
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		//利用驱动管理获得连接 
		try(
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/g2148", "root", "root");
			Statement st = conn.createStatement();
			){
			
			System.out.println("conn:" + conn);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
